import os


# def tree_dir(dirpath, level=1):
#     if level == 1:
#         print(dirpath)
#     dirs = os.listdir(dirpath)
#     for dir in dirs:
#         allFile = os.path.join(dirpath, dir)
#         if os.path.isdir(allFile):
#             print("\t"*level+"|"+"--"*level, dir)
#             tree_dir(allFile, level+1)
#         elif os.path.isfile(allFile):
#             print("\t"*level+"|"+"--"*level, dir)
#
#
# if __name__ == '__main__':
#     dirName = r"F:\开阔者"
#     tree_dir(dirName)

def tree_dir(paths="", level = 1):
    if level == 1:
        paths = raw_input("请输入绝对路径：")
        print(paths)
    dirs = os.listdir(paths)
    for dir in dirs:
        allFile = os.path.join(paths, dir)
        if os.path.isdir(allFile):
            print("\t"*level+"|"+"--"*level, dir)
            tree_dir(allFile,level+1)
        elif os.path.isfile(allFile):
            print("\t"*level+"|"+"--"*level, dir)

if __name__ == '__main__':
    tree_dir()




